package com.zboin.ucenter.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zboin.ucenter.mapper.RoleGroupMapper;
import com.zboin.ucenter.model.RoleGroup;
import com.zboin.ucenter.service.RoleGroupService;
import org.springframework.stereotype.Service;

/**
 * @author zhboom
 * @date 2025/8/4 23:40
 */
@Service
public class RoleGroupServiceImpl implements RoleGroupService {

    private final RoleGroupMapper roleGroupMapper;

    public RoleGroupServiceImpl(RoleGroupMapper roleGroupMapper) {
        this.roleGroupMapper = roleGroupMapper;
    }

    @Override
    public RoleGroup getRoleGroupById(Integer groupId) {
        return roleGroupMapper.selectById(groupId);
    }

    @Override
    public RoleGroup getRoleGroupByName(String groupName) {
        return roleGroupMapper.selectOne(new QueryWrapper<RoleGroup>().eq("group_name", groupName));
    }

    @Override
    public int addRoleGroup(RoleGroup roleGroup) {
        return roleGroupMapper.insert(roleGroup);
    }

    @Override
    public int updateRoleGroup(RoleGroup roleGroup) {
        return roleGroupMapper.updateById(roleGroup);
    }

    @Override
    public int deleteRoleGroup(Integer groupId) {
        return roleGroupMapper.deleteById(groupId);
    }
}
